//
//  PetInformationViewController.m
//  chongwu
//
//  Created by 隼目 on 2021/9/17.
//

#import "PetInformationViewController.h"
#import "PetInformationTableViewCell.h"

@interface PetInformationViewController ()<UITableViewDelegate,UITableViewDataSource,petInformationDelegate>
@property(nonatomic,strong)BaseTableView *tableView;

@property(nonatomic,strong)NSString *nameStr;
@property(nonatomic,strong)NSString *typeStr;
@property(nonatomic,strong)NSString *shapeStr;
@property(nonatomic,strong)NSString *scaleStr;
@property(nonatomic,strong)NSString *caseStr;
@property(nonatomic,strong)UIImage *dogImage;
@property(nonatomic,strong)UIImage *cradImage;
@end

@implementation PetInformationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"宠物信息填写";
    
    self.tableView=[BaseTableView new];
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(0);
    }];
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.backgroundColor=rgba(245, 246, 246, 1);
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    PetInformationTableViewCell *cell=[[PetInformationTableViewCell alloc] init];
    cell.delegate=self;
    cell.nameStr=self.nameStr;
    cell.typeStr=self.typeStr;
    cell.shapeStr=self.shapeStr;
    cell.scaleStr=self.scaleStr;
    cell.scaleStr=self.caseStr;
    cell.dogImage=self.dogImage;
    cell.cradImage=self.cradImage;
    if (indexPath.row==0) {
        [cell creatView];
    }else{
        [cell creatBtnView];
    }
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
    
}-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==0) {
        return 1118*_mainHeight;
    }
    return 167*_mainHeight;
}

-(void)textFiledDidEnd:(UITextField *)text{
    if (text.tag==1) {
        self.nameStr=text.text;
    }
}
-(void)textViewdDidEnd:(UITextView *)text{
    if (text.tag==5) {
        self.caseStr=text.text;
    }
}
-(void)selectEmpty{
    self.nameStr=nil;
    self.typeStr=nil;
    self.shapeStr=nil;
    self.scaleStr=nil;
    self.scaleStr=nil;
    self.dogImage=nil;
    self.cradImage=nil;
    [self.tableView reloadData];

}
-(void)selectSelectPicture:(NSInteger)index{
    SelectPictureView *view=[SelectPictureView new];
    [self.view.window addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    view.controller=self;
    view.SelectPictureBlock = ^(UIImage * _Nonnull image) {
        if (index==1) {
            self.dogImage=image;
        }else if (index==2) {
            self.cradImage=image;
        }
        
        [self.tableView reloadData];
    };
    [view creatView];
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
